// app/[lng]/tbe-last/page.tsx

import * as React from "react"
import { type SearchParams } from "@/types/table"
import { getValidFilters } from "@/lib/data-table"
import { getAllTBELast } from "@/lib/tbe-last/service"
import { searchParamsTBELastCache } from "@/lib/tbe-last/validations"
import { TbeLastTable } from "@/lib/tbe-last/table/tbe-last-table"
import { Shell } from "@/components/shell"
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"
import { Button } from "@/components/ui/button"
import { Plus } from "lucide-react"

interface TbeLastPageProps {
  params: {
    lng: string
  }
  searchParams: Promise<SearchParams>
}

export default async function TbeLastPage(props: TbeLastPageProps) {
  const resolvedParams = await props.params
  const lng = resolvedParams.lng
  
  const searchParams = await props.searchParams
  
  // Parse search params
  const search = searchParamsTBELastCache.parse(searchParams)
  const validFilters = getValidFilters(search.filters)
  
  // Load data
  const promises = Promise.all([
    getAllTBELast({
      ...search,
      filters: validFilters,
    })
  ])
  
  return (
    <Shell className="gap-2">
      <div className="flex items-center justify-between">
        <div>
          <h2 className="text-2xl font-bold tracking-tight">
            Technical Bid Evaluation (TBE)
          </h2>
          <p className="text-muted-foreground">
            RFQ 발송 후 기술 평가를 진행하고 문서를 검토합니다.
          </p>
        </div>
        
      </div>
      
      <React.Suspense
        fallback={
          <DataTableSkeleton
            columnCount={12}
            searchableColumnCount={1}
            filterableColumnCount={2}
            cellWidths={["10rem", "12rem", "20rem", "10rem", "15rem", "15rem", "20rem", "20rem", "10rem", "10rem", "8rem", "8rem"]}
            shrinkZero
          />
        }
      >
        <TbeLastTable promises={promises} />
      </React.Suspense>
    </Shell>
  )
}

// Metadata
export const metadata = {
  title: "TBE Management",
  description: "Technical Bid Evaluation for RFQ responses",
}